package lg.minecraft.plugin.pokedex.command;

import com.cobblemon.mod.common.api.pokemon.feature.FlagSpeciesFeature;
import com.cobblemon.mod.common.api.pokemon.feature.IntSpeciesFeature;
import com.cobblemon.mod.common.api.pokemon.feature.SpeciesFeature;
import com.cobblemon.mod.common.api.pokemon.feature.StringSpeciesFeature;
import com.cobblemon.mod.common.api.storage.party.PlayerPartyStore;
import com.cobblemon.mod.common.pokemon.Pokemon;
import com.cobblemon.mod.common.util.PlayerExtensionsKt;
import lg.minecraft.plugin.library.command.CommandContext;
import lg.minecraft.plugin.library.command.SubCommand;
import net.minecraft.class_3222;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.List;

/**
 * @author langle__
 * @version 1.0
 */
public class TestPokemon extends SubCommand {

    public TestPokemon(String name) {
        super(name);
    }

    @Override
    public String getDescription() {
        return "";
    }

    @Override
    public void onCommand(CommandContext context) {
        Player player = context.getPlayer();
        class_3222 nmsPlayer = PlayerExtensionsKt.getPlayer(player.getUniqueId());
        if (nmsPlayer == null) return;
        PlayerPartyStore party = PlayerExtensionsKt.party(nmsPlayer);
        for (int i = 0; i < party.size(); i++) {
            Pokemon pokemon = party.get(i);
            if (pokemon == null) continue;
            List<String> list = new ArrayList<>();
            for (SpeciesFeature feature : pokemon.getFeatures()) {
                if (feature == null) continue;
                switch (feature) {
                    case FlagSpeciesFeature flagFeature -> list.add(flagFeature.asString());
                    case IntSpeciesFeature intFeature -> list.add(intFeature.asString());
                    case StringSpeciesFeature stringFeature -> list.add(stringFeature.asString());
                    default -> list.add(feature.getName());
                }
            }
            player.sendMessage(i + ": " + String.join(", ", list));
        }
    }

}
